package cn.iocoder.yudao.module.crossborder.platform.dal.mysql.platformwebhook;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crossborder.platform.dal.dataobject.platformwebhook.PlatformWebhookDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crossborder.platform.controller.admin.platformwebhook.vo.*;

/**
 * 跨境电商平台Webhook配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PlatformWebhookMapper extends BaseMapperX<PlatformWebhookDO> {

    default PageResult<PlatformWebhookDO> selectPage(PlatformWebhookPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlatformWebhookDO>()
                .eqIfPresent(PlatformWebhookDO::getPlatformId, reqVO.getPlatformId())
                .eqIfPresent(PlatformWebhookDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(PlatformWebhookDO::getWebhookType, reqVO.getWebhookType())
                .eqIfPresent(PlatformWebhookDO::getEventType, reqVO.getEventType())
                .eqIfPresent(PlatformWebhookDO::getWebhookUrl, reqVO.getWebhookUrl())
                .eqIfPresent(PlatformWebhookDO::getSecretKey, reqVO.getSecretKey())
                .eqIfPresent(PlatformWebhookDO::getVerificationToken, reqVO.getVerificationToken())
                .eqIfPresent(PlatformWebhookDO::getHeadersConfig, reqVO.getHeadersConfig())
                .eqIfPresent(PlatformWebhookDO::getPayloadFormat, reqVO.getPayloadFormat())
                .eqIfPresent(PlatformWebhookDO::getRetryPolicy, reqVO.getRetryPolicy())
                .eqIfPresent(PlatformWebhookDO::getFilterConfig, reqVO.getFilterConfig())
                .eqIfPresent(PlatformWebhookDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PlatformWebhookDO::getEnabled, reqVO.getEnabled())
                .betweenIfPresent(PlatformWebhookDO::getLastTriggerTime, reqVO.getLastTriggerTime())
                .eqIfPresent(PlatformWebhookDO::getTriggerCount, reqVO.getTriggerCount())
                .eqIfPresent(PlatformWebhookDO::getSuccessCount, reqVO.getSuccessCount())
                .eqIfPresent(PlatformWebhookDO::getFailedCount, reqVO.getFailedCount())
                .eqIfPresent(PlatformWebhookDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(PlatformWebhookDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PlatformWebhookDO::getId));
    }

}